package com.first.homeqian.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.first.common.pojo.Order;
import com.first.homeqian.mapper.OrderMapper;
import com.first.homeqian.service.OrderService;
import com.first.homeqian.vo.OrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.math.BigDecimal;
import java.util.List;

/**
 * @program: SecondProject
 * @description:
 * @author: 李榕轩
 * @create: 2023-05-26 16:39
 **/
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;
    @Override
    public List<Order> findAll(String mobile) {
        QueryWrapper<Order> queryWrapper =new QueryWrapper<>();
        queryWrapper.eq("mobile",mobile);
        List<Order> orders = orderMapper.selectList(queryWrapper);
        return orders;
    }

    @Override
    public Double selectMoney() {
        List<Order> orders = orderMapper.selectList(null);
        BigDecimal i = BigDecimal.valueOf(0);
        for (Order order : orders) {

            BigDecimal money = BigDecimal.valueOf(Double.valueOf(order.getTotalFee()));
            i = i.add(money);

        }
        return i.doubleValue();
    }
}
